<?php

class Student {

	function __construct($id) {
		$query = mysql_query("SELECT * FROM `student` WHERE `id` = '$id';") or die(mysql_error());
		$result = mysql_fetch_object($query);
		if($result) {
			$this->id = $result->id;
			$this->full_name = $result->full_name;
			$this->email = $result->email;
			$this->group = $result->group;
		}
	}

	private function updateStudent() {
		$aliases = implode(',',$this->aliases);
		$query = mysql_query("UPDATE `student` SET `full_name` = '$this->full_name', `email` = '$this->email', `group` = '$this->group', `course` = '$this->course'") or die(mysql_error());
		return true;
	}

	public function getForumCount(){
		$query = mysql_query("SELECT * FROM `forum` WHERE `author` = '$this->id'") or die(mysql_error());
		$count = mysql_num_rows($query);
		return $count;
	}

	public function getSVNCount(){
		$query = mysql_query("SELECT * FROM `svn` WHERE `author` = '$this->id'") or die(mysql_error());
		$count = mysql_num_rows($query);
		return $count;
	}

	public function getWikiCount(){
		$query = mysql_query("SELECT * FROM `wiki` WHERE `author` = '$this->id'") or die(mysql_error());
		$count = mysql_num_rows($query);
		return $count;
	}

	public function getFileCount(){
		$query = mysql_query("SELECT * FROM `file` WHERE `author` = '$this->id'") or die(mysql_error());
		$count = mysql_num_rows($query);
		return $count;
	}

	public function getIssueCount(){
		$query = mysql_query("SELECT * FROM `issue` WHERE `author` = '$this->id'") or die(mysql_error());
		$count = mysql_num_rows($query);
		return $count;
	}
}